package com.yf.dao;

import com.yf.bean.AnswerBean;
import com.yf.entity.AnswerEntity;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class AnswerDao extends BaseDao {
    public int addAnswer(AnswerBean bean) {
        return sessionTemplate.insert(getStatement("addAnswer"), bean);
    }

    public int updateAnswer(AnswerBean bean) {
        return sessionTemplate.update(getStatement("updateAnswer"), bean);
    }

    public int disableAnswer(Integer id) {
        return sessionTemplate.update(getStatement("disableAnswer"), id);
    }

    public Integer getAnsUid(Integer id) {
        return sessionTemplate.selectOne(getStatement("getAnsUid"), id);
    }

    public AnswerBean getAnsByPidUid(Map<String, Integer> params) {
        return sessionTemplate.selectOne(getStatement("getAnsByPidUid"), params);
    }

    public List<AnswerEntity> getAnsByPid(Integer pid) {
        return sessionTemplate.selectList(getStatement("getAnsByPid"), pid);
    }

    public List<AnswerBean> getOnlyAnswerByPid(Integer pid) {
        return sessionTemplate.selectList(getStatement("getOnlyAnswerByPid"), pid);
    }
}
